package com.ysp;

/**
 * 深克隆
 */

/**
 * @author ysp
 * @date 2021/1/9 15:09
 */
public class Address implements Cloneable{
    private String location;

    public Address() {
    }

    public Address(String location) {
        this.location = location;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Override
    public String toString() {
        return "Address{" +
                "location='" + location + '\'' +
                '}';
    }

    @Override
    protected Address clone(){
        Address address = null;
        try {
            address = (Address) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return address;
    }
}
/*浅克隆
public class Address{
    private String location;

    public Address() {
    }

    public Address(String location) {
        this.location = location;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Override
    public String toString() {
        return "Address{" +
                "location='" + location + '\'' +
                '}';
    }
}
*/
